package com.fenghen.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class RabbitMQConfig {
    public static final String STOCK_QUEUE = "stockQueue";
    public static final String STOCK_EXCHANGE = "stockExchange";
    public static final String STOCK_ROUTING_KEY = "stock.reduce";

    @Bean
    public Queue stockQueue() {
        return new Queue(STOCK_QUEUE, true);
    }

    @Bean
    public TopicExchange stockExchange() {
        return new TopicExchange(STOCK_EXCHANGE);
    }


    @Bean
    public Binding binding() {
        return BindingBuilder.bind(stockQueue()).to(stockExchange()).with(STOCK_ROUTING_KEY);
    }


}
